angular.module('starter.controllers')
  .controller('listPerformanceCtr', function ($scope, preData, $state, $stateParams) {
    console.info("ctr");
    console.info(preData);
    console.info($stateParams);
    $scope.data = {};
    $scope.$on('$ionicView.loaded', () => {
      angular.copy($stateParams, $scope.data);
    });
    $scope.$on('$ionicView.beforeEnter', () => {
      var obj = window.localStorage.getItem('key');
      obj = angular.fromJson(obj);
      if (obj.d1 > 0) {
        $scope.data.d1 = obj.d1;
      }
      if (obj.d2 > 0) {
        $scope.data.d2 = obj.d2;
      }
    });
    var list = [];
    $scope.send = function (num) {
      var obj = {};
      obj.nums = num;
      setList(num);
      obj.list = list;
      $state.go('itemPerformance', obj);
    }

    $scope.sendOne = (num) => {
      var obj = {};
      obj.nums = num;
      setList(num);
      obj.list = list;
      $state.go('itemNgIfPerformance', obj);
    }

    var setList = (num) => {
      list=new Array();
      for (var i = 0; i < num; i++) {
        list.push(setItem(i));
      }
    }
    var setItem = (num) => {
      var item = {};
      item.id = num;
      item.name = 'Name' + num;
      item.index = 'Index' + num;
      return item;
    }


  });
